package com.atguigu.lease.web.app.config;

import com.atguigu.lease.web.app.interceptor.AuthenticationInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Value("${app.auth.path-patterns.include}")
    private String[] includes;
    @Value("${app.auth.path-patterns.exclude}")
    private String[] excludes;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器
        registry.addInterceptor(new AuthenticationInterceptor())
                .addPathPatterns(includes)
                .excludePathPatterns(excludes).order(1);
    }

}
